Annotations

Export Variables

Export FLAGS
@export: Export variables to Inspector
  • Exporting variables while defining a 'type' or 'range'.

    • @export var amount : float = 52.0

    • @export_range(0.0, 100.0, 3.0) var amount : float = 52.0

  • Improve visualization of exports in Inspector by defining a Group or Subgroup: (Very useful!)

    • @export_group(name: String, prefix: String = "")

    • @export_subgroup(name: String, prefix: String = "")

  • Resource export :

    • @export var resource : _class_name

  • Custom Resource export :

    • For this to work, the corresponding Resource Script must have a 'class_name', making it a valid Class to use as a 'Resource type'.

    • @export var resource : _custom_class_name

  • Not sure if these options work:

    • @export @onready var node : NodePath = get_node(node)

    • @export @onready var node : Node = get_node(node)

On Ready

@onready
  • Difference between @onready var  and var :

    • "var means you're setting the variable on initialization - which is before child creation. While @onready var  means you're creating the variable, waiting until all children have been created, and then setting the value after the node enters the tree."